package com.itheima.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class R {
    private Integer code;  // 1:成功 0:失败
    private String msg;    // 提示信息
    private Object data;    // 返回数据

    public static R ok(){
        R r = new R();
        r.setCode(1);
        return r;
    }

    public static R ok(Object data){
        R r = new R();
        r.setCode(1);
        r.setData(data);
        return r;
    }

    public static R error(String msg){
        R r = new R();
        r.setCode(0);
        r.setMsg(msg);
        return r;
    }
}
